package dataselect.infoManage;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import dao.MyDAO;

import javax.swing.JLabel;
import java.awt.Font;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.JButton;
import java.awt.Color;

public class InfoManage extends JFrame {

    private JPanel contentPane;

	/**
	 * Launch the application.
	 * @throws SQLException 
	 */
	public static void main(String[] args) throws SQLException {
		
		new InfoManage();
	}

	/**
	 * Create the frame.
	 * @throws SQLException 
	 */
	public InfoManage() throws SQLException {
		
		this.setVisible(true);
		this.setTitle("当前控制区：");
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 382);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("控制区管理信息");
		lblNewLabel.setFont(new Font("华文宋体", Font.BOLD, 16));
		lblNewLabel.setBounds(155, 10, 129, 31);
		contentPane.add(lblNewLabel);
		
		JLabel label = new JLabel("控制区名称：");
		label.setFont(new Font("华文宋体", Font.PLAIN, 15));
		label.setBounds(85, 73, 90, 15);
		contentPane.add(label);
		
		//显示控制区名称
		JLabel label_Name = new JLabel();
		label_Name.setFont(new Font("华文宋体", Font.BOLD, 16));
		label_Name.setBounds(239, 64, 142, 24);
		label_Name.setText("");
		contentPane.add(label_Name);
		
		JLabel label_1 = new JLabel("控制区总面积（亩）：");
		label_1.setFont(new Font("华文宋体", Font.PLAIN, 15));
		label_1.setBounds(85, 272, 155, 15);
		contentPane.add(label_1);
		
		//控制区总面积
		JLabel label_Area = new JLabel();
		label_Area.setFont(new Font("华文宋体", Font.BOLD, 16));
		label_Area.setBounds(239, 261, 129, 26);
		label_Area.setText("");
		contentPane.add(label_Area);
		
		JLabel lblNewLabel_3 = new JLabel("地理位置：");
		lblNewLabel_3.setFont(new Font("华文宋体", Font.PLAIN, 15));
		lblNewLabel_3.setBounds(85, 121, 117, 15);
		contentPane.add(lblNewLabel_3);
		
		//控制区地理位置
		JLabel label_Location = new JLabel();
		label_Location.setFont(new Font("华文宋体", Font.BOLD, 16));
		label_Location.setBounds(239, 110, 142, 26);
		label_Location.setText("");
		contentPane.add(label_Location);
		
		JLabel lblNewLabel_5 = new JLabel("管理员姓名：");
		lblNewLabel_5.setFont(new Font("华文宋体", Font.PLAIN, 15));
		lblNewLabel_5.setBounds(85, 172, 100, 15);
		contentPane.add(lblNewLabel_5);
		
		//管理员姓名
		JLabel label_Admin = new JLabel();
		label_Admin.setFont(new Font("华文宋体", Font.BOLD, 16));
		label_Admin.setBounds(239, 161, 142, 26);
		label_Admin.setText("");
		contentPane.add(label_Admin);
		
		JLabel label_2 = new JLabel("联系方式：");
		label_2.setFont(new Font("华文宋体", Font.PLAIN, 15));
		label_2.setBounds(86, 213, 129, 26);
		contentPane.add(label_2);
		
		Connection conn = null;
		Statement stmt = null;
		ResultSet rSet = null;
		try {
			conn = MyDAO.getConnection();
			stmt = conn.createStatement();
			String sql = "select admin.phone from admin where admin.nickname = 'aaa' ";
			rSet = stmt.executeQuery(sql);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		//联系方式
		JLabel label_Phone = new JLabel();
		label_Phone.setFont(new Font("华文宋体", Font.BOLD, 16));
		label_Phone.setBounds(239, 213, 142, 26);
		contentPane.add(label_Phone);
		while (rSet.next()) {
			label_Phone.setText(rSet.getString(1));
			System.out.println(rSet.getString(1));
		}
		
		rSet.close();
		stmt.close();
		conn.close();
		this.setLocationRelativeTo(null);
	}

}
